
package org.platform.core.filecommand.impl;


import com.mc.mic.core.log.bus.BusLogPusher;
import com.mc.mic.core.log.frame.LogBo;
import com.mc.mic.core.tool.helper.SpringContextHelper;
import lombok.extern.slf4j.Slf4j;
import org.platform.constant.LogType;
import org.platform.core.filecommand.IFileCommand;
import org.platform.mo.bussmo.log.OperationMqBO;
import org.platform.processor.knowledge.KnowledgeApplyReceiveProcessor;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 知识申请处理类
 * Created by mabb on 15-1-26.
 */
@Slf4j
public class KnowApplyFileCommand implements IFileCommand {
    @Autowired
    private KnowledgeApplyReceiveProcessor processor;
    @Autowired
    private BusLogPusher mqLog;


    public KnowApplyFileCommand() {
        if (null == processor) {
            processor = SpringContextHelper.getBean(KnowledgeApplyReceiveProcessor.class);
        }
        if (null == mqLog) {
            mqLog = SpringContextHelper.getBean(BusLogPusher.class);
        }
    }

    @Override
    public boolean doCommandAck(String filePath, String fileName, String txtMsg) {
        String operation = "接收到知识申请文件,正在执行知识申请响应流程";
        mqLog.log(new LogBo<>(LogType.OPERATION_LOG, new OperationMqBO(operation)));
        log.info(operation);
        processor.addKnowledge(txtMsg);
        return true;
    }
}
